package states.gameplay;

import java.util.ArrayList;
import java.util.List;

import states.gameplay.shapors.Base;
import states.gameplay.shapors.Defender;
import states.gameplay.shapors.Wallor;

public class Player {
	private int _maximumEnergy;
	private int _currentEnergy;
	
	// base
	private Position _basePosition;
	private Base _base;
	
	private List<Defender> _defenders;
	private List<Wallor> _wallors;
	
	private int LastEnergyConsumption;
	private int LastEnergyGeneration;
	
	private int defenseLevel;
	
	public Player(int startEnergy, Position basePos, Base base){
		setCurrentEnergy(startEnergy);
		
		setMaximumEnergy(startEnergy); 
		
		setBasePosition(basePos);
		
		setDefenders(new ArrayList<Defender>());
		
		_wallors = new ArrayList<Wallor>();
		
		setDefenseLevel(2);
		
		_base = base;
	}
	
	public int getMaximumEnergy(){
		return _maximumEnergy;
	}
	
	public void setMaximumEnergy(int maximumEnergy){
		
		_maximumEnergy = maximumEnergy;
		
		if(getCurrentEnergy() > _maximumEnergy){
			setCurrentEnergy(_maximumEnergy);
		}
	}
	
	public void addToCurrentEnergy(int amount){
		if(amount > 0){
			_currentEnergy += amount;
			
			if(_currentEnergy > _maximumEnergy){
				_currentEnergy = _maximumEnergy;
			}
		}
	}
	
	public void removeFromCurrentEnergy(int amount){
		if(amount > 0){
			_currentEnergy -= amount;
			
			if(_currentEnergy < 0){
				_currentEnergy = 0;
			}
		}
	}

	public Position getBasePosition() {
		return _basePosition;
	}

	private void setBasePosition(Position basePosition) {
		this._basePosition = basePosition;
	}

	public Base getBase() {
		return _base;
	}

	public int getCurrentEnergy() {
		return _currentEnergy;
	}

	public void setCurrentEnergy(int _currentEnergy) {
		this._currentEnergy = _currentEnergy;
	}

	public boolean canSpend(int cost) {
		return _currentEnergy >= cost;
	}

	public List<Defender> getDefenders() {
		return _defenders;
	}

	private void setDefenders(List<Defender> defenders) {
		this._defenders = defenders;
	}

	public List<Wallor> getWallors() {
		return _wallors;
	}

	public int getDefenseLevel() {
		return defenseLevel;
	}

	public void setDefenseLevel(int defenseLevel) {
		this.defenseLevel = defenseLevel;
	}

	public int getLastEnergyConsumption() {
		return LastEnergyConsumption;
	}

	public void setLastEnergyConsumption(int lastEnergyConsumption) {
		LastEnergyConsumption = lastEnergyConsumption;
	}

	public int getLastEnergyGeneration() {
		return LastEnergyGeneration;
	}

	public void setLastEnergyGeneration(int lastEnergyGeneration) {
		LastEnergyGeneration = lastEnergyGeneration;
	}

}
